package com.ttdevs.ttrss.ui;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.ttdevs.customviewpager.custom.TabSwipPager;
import com.ttdevs.ttrss.R;
import com.ttdevs.ttrss.ui.left.SourceFragment;
import com.ttdevs.ttrss.ui.right.GroupFragment;
import com.ttdevs.ttrss.ui.right.SettingFragment;

public class RightFragment extends Fragment {
	private CustomActivity activity;

	private LinearLayout llTabSwipPager;
	private TabSwipPager tabSwipPager;
	private ArrayList<Fragment> fragmentsList;
	private String[] tags;

	@Override
	public void onAttach(Activity activity) {
		this.activity = (CustomActivity) activity;
		super.onAttach(activity);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.content_right, container, false);
		initView(view);
		return view;
	}

	private void initView(View view) {
		initData();
		llTabSwipPager = (LinearLayout) view.findViewById(R.id.llTabSwipPager);
		tabSwipPager = new TabSwipPager(activity.getApplicationContext(), activity.getSupportFragmentManager(), llTabSwipPager);
		if (!tabSwipPager.setFragmentList(fragmentsList, tags)) {
			System.out.println("初始化失败");

		}
	}

	private void initData() {
		fragmentsList = new ArrayList<Fragment>();
		fragmentsList.add(new SourceFragment());
		fragmentsList.add(new GroupFragment());
		fragmentsList.add(new SettingFragment());

		tags = new String[] { "订阅", "分组", "设置" };

	}
}
